package com.aaa.boot.controller;

import com.aaa.boot.pojo.vo.CategoryVO;
import com.aaa.boot.pojo.vo.GoodVO;
import com.aaa.boot.pojo.vo.GoodsVO;
import com.aaa.boot.result.AjaxResult;
import com.aaa.boot.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author MK
 * @version 1.0
 * 创建时间：2025/4/2 16:25
 */
@RestController
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @GetMapping
    public AjaxResult getCategories(){
        List<CategoryVO> categories = goodsService.getCategories();
        return new AjaxResult(200,"获取列表信息成功",categories);
    }

    // id:分类id
    @GetMapping("getGoods")
    public AjaxResult getGoodsByCategoryId(Integer id){
        List<GoodsVO> goods = goodsService.getGoodsByCategoryId(id);
        return new AjaxResult(200,"获取所有菜信息成功",goods);
    }

    // id:商品id
    @GetMapping("getGood")
    public AjaxResult getGoodById(Integer id){
        GoodVO goods = goodsService.getGoodById(id);
        return new AjaxResult(200,"获取菜信息成功",goods);
    }

    @GetMapping("getBanners")
    public AjaxResult getBannersByCategoryId(Integer id){
        List<String> banners = goodsService.getBannersByCategoryId(id);
        return new AjaxResult(200,"获取banner成功",banners);
    }

}
